// 导入单个组件
import WhForm from './wh-form/index'
import WhTable from './wh-table/index'
import WhButton from './wh-button/index'
import WhDialog from './wh-dialog/index'
import WhDrawer from './wh-drawer/index'
import WhBoot from './wh-boot/index'

// console.dir(WhForm)
// 以数组的结构保存组件，便于遍历
// const components = [WhForm, WhTableForm, WhTable, WhButton, WhDialog, WhBoot]
const components = [WhForm, WhTable, WhButton, WhDrawer, WhDialog, WhBoot]

// 定义 install 方法
const install: any = function (Vue: any) {
  if (install.installed) return
  install.installed = true
  // 遍历并注册全局组件
  components.map((component: any) => {
    // console.dir(Vue, '------name------')
    Vue.component(component.extendOptions.name, component)
  })
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}

export default {
  // 导出的对象必须具备一个 install 方法
  install,
  // 组件列表
  ...components
}
